<template>
  <div class="windowTool">
    <div @click="minisize">
      <i class="iconfont icon-zuixiaohua"></i>
    </div>
    <div type="text" v-if="isMaxSize" @click="maxsize">
      <i class="iconfont icon-3zuidahua-1"></i>
    </div>
    <div type="text" v-else @click="restore">
      <i class="iconfont icon-3zuidahua-3"></i>
    </div>
    <div type="text" @click="close">
      <i class="iconfont icon-guanbi"></i>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue'
import { ipcRenderer } from 'electron'

export default defineComponent({
  setup() {
    const isMaxSize = ref(false)
    const minisize = () => {
      ipcRenderer.send('minisize-app')
    }
    const restore = () => {
      ipcRenderer.send('restore-app')
      isMaxSize.value = true
    }
    const maxsize = () => {
      ipcRenderer.send('maxsize-app')
      isMaxSize.value = false
    }
    const close = () => {
      ipcRenderer.send('close-app')
    }

    return { isMaxSize, minisize, restore, maxsize, close }
  }
})
</script>

<style scoped lang="less">
.windowTool {
  margin-right: 10px;
  -webkit-app-region: no-drag;
  display: flex;
  align-items: center;
  div {
    margin-left: 32px;
  }
}
</style>
